<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>项目执行文件管理</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  <meta name="apple-mobile-web-app-capable" content="yes"/>
  <link type="text/css" rel="stylesheet" href="/lib/budget/styles.css"/>
  <link type="text/css" rel="stylesheet" href="/lib/pagination/style/pagination.css">
  <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>

  <script type="text/javascript" charset="utf-8" src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js"></script>
  <script type="text/javascript" charset="utf-8" src="/lib/pagination/js/jquery.pagination.min.js"></script>
  <script type="text/javascript" charset="utf-8" src="/js/base/tablePage.js"></script>
  <script type="text/javascript" charset="utf-8" src="/lib/layer/layer.js?20201106"></script>
  <script type="text/javascript" src="/js/base/base.js?20190621"></script>
  <style>
    *{
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    body{
      width: 100%;
    }
    table{
      width:100%;
      border-collapse: collapse;
      margin-left: 7px;
      table-layout: fixed;
    }
    .minHeight{
      min-height: 140px;
    }
    th{
      width:30%;
      padding: 0 5px;
      /*border: 1px solid #666666;*/
      height: 40px;
      font-size: 13px;
      line-height: 40px;
      color: #333;
      /*溢出隐藏并显示...*/
      /*word-break: keep-all;*/
      /*white-space: nowrap;*/
      /*text-overflow: ellipsis;*/
      /*-webkit-box-orient: vertical;*/
      /*overflow: hidden;*/
      text-align: center;
    }
    td{
      width:30%;
      padding: 0 5px;
      /*border: 1px solid #666666;*/
      height: 40px;
      font-size: 13px;
      line-height: 40px;
      color: #333;
      /*溢出隐藏并显示...*/
      word-break: keep-all;
      white-space: nowrap;
      text-overflow: ellipsis;
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-align: center;


    }

    th{
      /*background-color: #00ccff;*/
      /*color:#2F5C8F;*/
      color: rgb(47, 92, 143);
      font-size: 13px
    ;
    }
    .th1,.th5{
      width: 63px;
    }
    .th2{
      width: 100px;
    }
    #add{
      font-size: 14px;
      background-color: #2b7fe0;
      padding: 4px 18px;
      border-radius: 3px;
      color: #fff;
      cursor:pointer;
    }
    #clear{
      font-size: 14px;
      background-color: #2b7fe0;
      padding: 4px 18px;
      border-radius: 3px;
      color: #fff;
      cursor:pointer;
    }
    .th3{
      width: 100px;
    }
    .th4{
      width: 82px;
    }

    .th6{
      width: 76px;
    }
    .th7,.th8,.th9{
      width: 76px;
    }

    .th10{
      width: 94px;
    }
    .th11{
      width: 103px;
    }
    .th12{
      width: 82px;
    }
    .th13{
      width:  151px;
    }
    .th14{
      width: 93px;
    }
    .p1{
      float: left;
      margin-bottom: 0;
      height: 32px;
      padding-left: 10px;
      font-size: 18px;
      line-height: 32px;
      color: #333;
    }
    .p2{
      float: right;
      height: 40px;
      margin-right: 25px;
    }
    .clearfix:after {
      display: table;
      content: " ";
      clear: both;
    }
    .clearfix{
      border-bottom:1px solid #9e9e9e;
      margin-bottom: 16px;
      height:36px;
    }
    .p2 span{
      font-size: 14px;
      background-color: #2b7fe0;
      padding: 4px 18px;
      border-radius: 3px;
      color: #fff;
      cursor: pointer;
    }
    .bspan{
      font-size: 14px;
      background-color: #2b7fe0;
      padding: 4px 18px;
      border-radius: 3px;
      color: #fff;
      cursor: pointer;
    }

    .main{
      /*margin-right: 1%;*/
      margin-top: 1%;
    }
    .nav-r{
      font-size: 20px;
      color: #FF0000;
      margin-left: 535px;
    }


    .biginput{
      width: 40%;
      height: 32px;
      font-size: 13px;
    }
    .foot{
      font-size: 14pt;
      /* margin-top: 58px; */
      width: 100%;
      padding: 5%;
    }
    .foot p{
      /*margin: 20px 0; */
      border-bottom: 1px solid #000;
      height: 40px;
      /* padding-left: 8px; */
    }

    /*.save span{*/
      /*padding: 6px 54px;*/
      /*font-size: 20px;*/
      /*background-color: #008cffd9;*/
      /*border-radius: 5px;*/
      /*margin-left: 162px;*/
      /*color: #fff;*/
      /*cursor:pointer;*/
    /*}*/

    tr:hover{
      background: #dedede;
      cursor:pointer;
    }
    a{
      text-decoration: none;
      color: rgb(43, 127, 224);
    }
    .dr,.dc,.new,.quanx{
      cursor:pointer;
    }
    .p2 span {
      font-size: 14px;
      background-color: #2b7fe0;
      padding: 4px 18px;
      border-radius: 3px;
      color: #fff;
      cursor: pointer;
    }
    .dr:hover,.dc:hover,.new:hover,.quanx:hover,.bspan:hover{
      background-color:#0e6bb7d9;
      color: #fff;
      cursor:pointer;
    }
    /*.quanx,.foot{*/
      /*display: none;*/
    /*}*/
    ul,li{
      list-style: none;
    }
    li{
      margin: 25px 0;
    }
    .del:hover{
      color: red;
    }
    .del:hover, .bianji:hover,.mingxi:hover{
      color: #CC2222;
      text-decoration: underline;
    }
    .td_title1{
      width: 40%;
      height:32px;
    }
    .ml8{
      margin-left:8px;
    }

    input[type="file"]{

      margin-left: 8px;
    }
    .importTable{
      margin:60px auto;
    }

    #model{
      padding-left:8px;
    }
/*分页样式*/
    .M-box3{
      margin-top: 30px;
      float: right;
      /*position: fixed;*/
      /*right: 60px;*/
      /*bottom:10px;*/
      text-align: center;
    }
    input[type="text"]{
      position: relative;
      margin: 0;
      padding-left: 10px;
      box-sizing: border-box;
      border: 1px solid rgb(221, 221, 221);
      border-image: initial;
      border-radius: 4px;
    }

    .jump-ipt{
      width: 38px;
      height: 38px;
      line-height: 38px;
    }
    .div_Img{
      float:left;
      margin-left: 34px;
    }
    tbody tr:nth-child(2n+1) {
      /* background-color: rgb(246, 247, 249);*/
      background-color: rgb(255, 255, 255);
    }
    tbody tr:nth-child(2n) {
      /*background-color: rgb(255, 255, 255);*/
      background-color: rgb(246, 247, 249);
    }
    #uploadTable tr {
      border-width: 1px;
      border-style: solid;
      border-color: rgb(192, 192, 192);
      border-image: initial;
    }
    #uploadTable tr:hover{
      background-color:#d3e6f9;
    }
    .M-box3 .active{
      margin: 0px 3px;
      width: 38px;
      height: 38px;
      line-height: 38px;
      background: #2b7fe0;
      font-size: 12px;
      border: 1px solid #2b7fe0;
      color:#fff;
      text-align:center;
      display: inline-block;
    }
    .M-box3 a{
      margin: 0 3px;
      width: 38px;
      height: 38px;
      line-height: 38px;
      font-size: 12px;
      display: inline-block;
      text-align:center;
      background: #fff;
      border: 1px solid #ebebeb;
      color: #333;
      text-decoration: none;
    }
    .jump-ipt {
      width: 38px;
      height: 38px;
      line-height: 38px;
      text-align: center;
      padding: 0;
    }
    .M-box3 a:hover {
      background: #2b7fe0;
    }
    .search_div{
      margin: 0 30px;
      margin-bottom: 10px;
    }
    .search_div label{
      vertical-align: middle;
      margin-left: 8px;
    }
    .year{
      width: 168px;
      height: 29px;
      line-height: 29px;
      border-radius: 4px;
      margin-right: 10px;
    }
    .jump-ipt{
      float: left;
    }
    #query{
      width: 71px;
      height: 24px;
      font-family: 'Arial Normal', 'Arial';
      font-style: normal;
      font-size: 13px;
      color: #fff;
      background: #2b7edf url(../../img/taisousuo.png) no-repeat 12px 5px!important;
      border: none;
      padding-left: 20px;
      border-radius: 5px;
      display: inline-block;
      text-align: center;
      line-height: 24px;
      cursor:pointer;
    }
    #uploadTable td:nth-child(3){
      text-overflow: clip;
      white-space: normal;
      line-height: 20px;
      word-break: initial;
    }
    .layui-layer{
      top:200px!important;
    }
  </style>
</head>
<body>
  <div class="main">
    <div class="clearfix">

      <input type="hidden" value="${sessionScope.module}" id="module">
      <div class="div_Img">
        <img src="/img/xmgl.png" style="vertical-align: middle;" alt="菜单主分类设置">
      </div>
      <p class="p1">预算项目管理</p>
      <div class="p2">
        <span class="waitDel"><img style="margin-right: 3px;margin-left: -8px;margin-bottom: -2px;" src="../../img/daichehui.png" alt="">待撤回</span>
        <span class="dc" id="outport"><img style="margin-right: 3px;margin-left: -8px;margin-bottom: -2px;" src="../../img/daochu.png" alt="">导出</span>
        <span  class="dr add" id="inport"><img style="margin-right: 3px;margin-left: -8px;margin-bottom: -2px;" src="../../img/daoru.png" alt="">导入</span>
        <span class="new"><img style="margin-right: 3px;margin-left: -8px;margin-bottom: -2px;" src="../../img/newxinjian.png" alt="">新建</span>
        <%--<span class="quanx">权限设置</span>--%>
      </div>
    </div>
    <div class="search_div" style="font-size: 12px;">
      <label>
        <select class="year"></select>
      </label>
      <label for="">
        <span>所属部门：</span>
        <select name="" id="deptName" style="width: 100px;
    height: 28px;
    border-radius: 3px;"></select>
      </label>
      <label for="">
        <span>项目执行人：</span>
        <input id="user" placeholder="" type="text" value="" readonly="readonly" style="width: 100px;
    height: 28px;
    border-radius: 3px;">
        <a href="javascript:;" class="add4" >添加</a>
        <a href="javascript:;"  class="clear">清空</a>
      </label>
      <span id="query">查询</span>

    </div>
    <div id="u268" style="margin:0 30px">
      <div class="minHeight">
        <table id="uploadTable" style="width:100%;margin: 0 auto;table-layout: fixed">
          <thead>
          <tr style="background: none">
            <th class="th1">项目编号</th>
            <th class="th2">上级项目</th>
            <th class="th3">项目名称</th>

            <th class="th5">额度号</th>
            <th class="th6">项目金额</th>
            <th class="th6">剩余金额</th>
            <th class="th6">预支出金额</th>
            <th class="th7">项目负责人</th>
            <th class="th8">所属部门</th>
            <th class="th9">项目执行人</th>
            <th class="th4">指标分类</th>
            <th class="th13">操作</th>
            <%--<th class="th14">日志</th>--%>
          </tr>
          </thead>
          <tbody>

          </tbody>

        </table>
      </div>


      <div class="row" style="margin-top: 20px;    margin-left: 0%;">
        <div class="pull-left" style="display:inline-flex;">
          <span id="total"></span>
          <span style="margin-left:5px;">每页显示
            <select id="forPage">
                <option value="5">5</option>
                <option value="10">10</option>
                <option value="20">20</option>
                <option value="50">50</option>
                <option value="100">100</option>
            </select>
            条记录</span>
        </div>
        <div id="page1" class="pull-right"></div>
      </div>
      <div id="dbgz_page" class="M-box3 fr" style="margin-top: -20px; margin-right: 0%;">

      </div>

    </div>

</div>
</body>
<script>
  var yusuan = '';
    function undefindData(data) {
        if(data == undefined){
            return '';
        }else{
            return data;
        }
    }

    $.ajax({
        type:'get',
        url:'/department/getChDeptfq?deptId=0',
        dataType:'json',
        success:function(res){
            var str1='';
            var arr = res.obj;
            if(res){
                str1 = '<option value="">请选择</option>'
                for (var i = 0; i < arr.length; i++) {
                    var item = arr[i];
                    str1 += '<option value="'+undefindData(item.deptId)+'">' + undefindData(item.deptName) + '</option>'
                }
                $('#deptName').html(str1)
            }

        }
    })
    $('.add4').click(function(){
        user_id='user';
        $.popWindow("../../common/selectUser?0");
    })
    $('.clear').click(function () {
        $('#user').attr("userName", "");
        $('#user').attr("user_id", "");
        $('#user').val("");
    });
    //导入
    $('#inport').click(function(){

        if(!matchString($('#module').val(),'5')&&$('tbody tr').length>=3){
            $.layerMsg({content:'预算管理为可选组件，内置版本为试用版，限制建立3个预算项目，如需购买本组件请联系开发厂商'})
            return ;
        }else{
            layer.open({
                type:1,
                title: ['预算项目信息导入', 'background-color:#2b7fe0;color:#fff;'],
                area: ['600px', '420px'],
                btn: ['导入', '取消'],
                content:'<div>' +
                '<form class="form1" name="form1" id="uploadForm" method="post" action="/budget/importBudgetItem" enctype="multipart/form-data">' +
                '<table class="importTable"> ' +
                '<tr><td style="width: 26%;">下载导入模板：</td><td style="text-align: left;width: 60%;"><a id="model" style="cursor:pointer;text-decoration: underline;color: blue;">预算项目信息模板下载</a></td></tr>' +
                '<tr> <td>选择导入文件：</td> <td style="text-align: left"><input style="width: auto" type="file" name="file"/></td> </tr>' +
                '<tr>' +
                '<td>说明：</td>'+
                '<td style="text-align: left;"><p style="margin-left: 8px">1、请导入.xls或.xlsx文件</p>'+

                ' </td> ' +
                '</tr>' +
                '</table>' +
                '</form>' +
                '</div>',
                success:function(){
                    $('#model').click(function () {
                        window.location.href = encodeURI("/file/budget/预算项目导入模板.xls");
                    });
                },
                yes:function(obj){
                    var flag = CheckForm();
                    if (flag) {
                        layer.msg("正在导入中，请耐心等候", {icon: 1});
                        $.upload($('#uploadForm'), function (res) {
                            if(res.msg=="导入项目重复"){
                                layer.msg("导入项目重复", {icon: 2});
                            }else
                            if(res.flag) {
                                layer.msg("导入成功", {icon: 1});
                                window.location.reload();
                            }else{
                                layer.msg("导入失败", {icon: 2});
                            }
                        });

                        layer.closeAll();
//

                    }
                }
            })
        }




    })
    function CheckForm(){
        if(document.form1.file.value==""){
            layer.msg("请导入至少一条数据！",{icon:2});
            return (false);
        }
        return (true);
    }


    $(function(){

        var years = '<option value="" >请选择年份</option>';
        for(var lastYear = parseInt(new Date().getFullYear()+4),oldYear = 2016;lastYear>oldYear;lastYear--){
            years += '<option value="'+lastYear+'" >'+lastYear+'</option>'
        }
        $('.year').html(years);
        var yearss = new Date().getFullYear();
        $('.year').val(yearss);

        $('.year').change(function () {
            var year = $(this).find("option:selected").val();
            ajaxPage.data.year = year;
            ajaxPage.page();
        })

      $('.new').click(function(){
          if(!matchString($('#module').val(),'5')&&$('tbody tr').length>=3){
              $.layerMsg({content:'预算管理为可选组件，内置版本为试用版，限制建立3个预算项目，如需购买本组件请联系开发厂商。'});
              return ;
          }else{
              window.location.href='/budget/newBudget?type=1';
          }

      });
      $('.waitDel').click(function(){
          window.location.href='/budget/newdel';
      });
      $('table').on('click','.bianji',function(){
          var budgetId=$(this).parent().parent().attr('budgetId');
          var priveItem=$(this).parent().parent().attr('priveItem');
          window.location.href='/budget/newBudget?type=2&budgetId='+budgetId+'&priveItem='+priveItem;
      });

      $('table').on('click','.mingxi',function(){
          var budgetId=$(this).parent().parent().attr('budgetId');
          // alert(budgetId)
          // window.open('/budget/newjournal?type=3&budgetId='+budgetId)
          window.location.href='/budget/newjournal?type=3&budgetId='+budgetId;
      });
      function undefindData(data) {
          if(data == undefined){
              return '';
          }else{
              return data;
          }
      }

//      $.ajax({
//          type:'get',
//          url:'/budget/selAllBudget',
//          dataType:'json',
//
//          success:function(res){
//              var str='';
//              if(res){
//                  console.log(res.obj);
//                  $.each(res.obj,function(index,item){
//                    str+= '<tr budgetId="'+item.budgetId+'" indata="'+item.inputTime+'">'+
//                            '<td>'+item.budgetItemNo+'</td>'+
//                            '<td>'+item.priveItem+'</td>'+
//                            '<td>'+item.budgetItemName+'</td>'+
//                            '<td>'+item.quotaClassify+'</td>'+
//                            '<td>'+item.lineNo+'</td>'+
//                            '<td>'+item.itemMoney+'</td>'+
//                            '<td>'+item.itemManager+'</td>'+
//                            '<td>'+undefindData(item.department)+'</td>'+
//                            '<td>'+item.itemExecuter+'</td>'+
//                            '<td>'+function(){
//                                    if(item.isOpen==0){
//                                        var str='<a class="mingxi" href="javascript:;">填报明细 </a> <a href="javascript:;" class="bianji">编辑 </a> <a href="javascript:;" class="del" >删除 </a>'
//                                        return  str
//                                    }else if(item.isOpen==1){
//                                        var str1='<a class="mingxi" href="javascript:;">填报明细 </a>'
//                                        return  str1
//                                    }
//                            }()+'</td>'+
////                            '<td><a class="mingxi" href="javascript:;">填报明细 </a> <a href="javascript:;" class="bianji">编辑 </a> <a href="javascript:;" class="del" >删除 </a></td>'+
//                          '</tr>'
//
//                      if(item.budgetLogSet==0){
//                        $('.quanx').css('display','inline-block')
//                      }
//                  })
//                  $('table').append(str)
//              }
//
//          }
//      })
      $('table').on('click','.del',function(){
          var budgetId=$(this).parent().parent().attr('budgetId')
          var budgetItemName=$(this).parent().parent().children().eq(3).html()
          var writerName = $(this).parent().parent().attr('indata')
          layer.open({
              type: 1,
              title: ['提示','background-color:#2e8ded;color:#fff'],
              content:'<div style="text-align: center;margin-top: 18px;">确认删除吗？</div>',
              area: ['200px', '160px'],
              btn: ['确认','取消'],
              yes:function(index){
                  $.ajax({
                      url:'/budget/delBudgetItemById?type=0',
                      type:'post',
                      data:{
                          'budgetId':budgetId,
                          'budgetItemName':budgetItemName,
                          'inputTime':writerName
                      },
                      dataType:'json',

                      success:function(res){
                          layer.close(index)
                          if(res){
                            layer.msg("删除成功",{
                                icon: 1,
                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                location.href="/budget/budgetItemManage"
                            })
                          }else {
                              layer.msg("删除失败",{
                                  icon: 2,
                                  time: 1500 //2秒关闭（如果不配置，默认是3秒）
                              },function(){
                                  location.href="/budget/budgetItemManage"
                              })
                          }
                      }
                  })
              },
              btn2: function (index) {
                  layer.close(index)
              },
              btnAlign:'c',

          })
      });

//权限设置
      $('.quanx').on('click',function () {
          layer.open({
              type: 1,
              title: ['预算管理日志权限设置', 'background-color:#2b7fe0;color:#fff;'],
//            area: ['500px', '460px'],
              area: ['60%', '70%'],
              shadeClose: false, //点击遮罩关闭
              btn: ['保存', '取消'],
              content: '<div class="foot">' +
              '<p>预算管理日志权限设置</p>' +
              '<ul>' +

              '<li>' +
              '<span>人员：&emsp;&emsp;&emsp;&emsp;</span>' +
              '<span style="position: relative;">' +
              '<input disabled class="td_title1 release1" id="query_toId" type="text" username="">' +
              '<a href="javascript:;" class=" ml8 userPrivAdd userAdd" id="add" name="orgAdd">添加</a>' +
              '<a href="javascript:;" class=" ml8 userPrivClear userClear" id="clear" name="orgClear">清除</a>' +
              '</span>' +
              '</li>' +
              '<li>' +
              '<span>角色：&emsp;&emsp;&emsp;&emsp;</span>' +
              '<span style="position: relative;">' +
              '<input disabled type="text" name="userPriv" id="userPrivInput"  class="BigInput" value="" privid="" userpriv="">' +
              '<a href="javascript:;" class="ml8 userPrivAdd privAdd" id="add" name="orgAdd" >添加</a>' +
              '<a href="javascript:;" class="ml8 userPrivClear privClear" id="clear" name="orgClear">清除</a>' +
              '</span>' +
              '</li>' +

              '</ul>' +
              '</div>',
//            保存按钮事件
              yes:function (index) {
                  var data={
                      userIds:$("#query_toId").attr("user_id"),
                      userPrivIds:$("#userPrivInput").attr("privid"),
//                    flowId:$("#department").val(),
                      flowId:$('input:checkbox[name="rz"]:checked').val(),
                      documentType:0,
                      dispatchType:'documentDecision',
                      fflowId:$('input:checkbox[name="rz"]:checked').val(),
                      frunId:'',
                      fprcsId:1,
                      fflowStep:1,
                      useFlag:true
                  };
                  newDocument(data,function(json){
                      if(json.flag){
                          location.reload();
//                          window.open('/documentCenter/handleMain/window?flowId='+json.object.flowId+'&flowStep=1&tableName=document&tabId='+json.object.id+'&runId='+json.object.runId+'&prcsId=1&isNomalType=false')
//                          window.open('budget/upBudgetLogSet')

                          layer.msg("保存成功",{
                              icon: 1,
                              time: 1500 //2秒关闭（如果不配置，默认是3秒）
                          },function(){
                              window.location.reload();
                          });

                      }else {
                          alert("保存失败");
                      }
                      layer.close(index);
                  });

              },

              success:function () {


                  // 获取人员信息控件
                  $(".userAdd").on("click", function (){
                      user_id = "query_toId";
                      $.popWindow("../common/selectUser");
                  });
                  // 清空人员信息
                  $('.userClear').click(function () {
                      $('#query_toId').attr("privid", "");
                      $('#query_toId').attr("userpriv", "");
                     // $('#query_toId').val("");
                      $.ajax({
                          url:'/budget/delBudgetLog',
                          type:'post',

                          dataType:'json',
                          success:function(result){
                              if(result.msg=='ok'){
                                  layer.msg("取消成功",{
                                      icon: 1,
                                      time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                  },function(){
                                      window.location.reload();
                                  });

                              }

                          },
                          error:function(){

                          }
                      });
                  });
                  //获取角色信息控件
                  $(".privAdd").on("click", function (){
                      priv_id = "userPrivInput";
                      $.popWindow("../common/selectPriv");
                  });
                  // 清空角色信息
                  $('.privClear').click(function () {
                      $('#userPrivInput').attr("privid", "");
                      $('#userPrivInput').attr("userpriv", "");
                      $('#userPrivInput').val("");
                  });
                  //取消权限
                  $('.cancelQx').click(function () {
                      $.ajax({
                          url:'/budget/delBudgetLog',
                          type:'post',

                          dataType:'json',
                          success:function(result){
                              if(result.msg=='ok'){
                                      layer.msg("取消成功",{
                                          icon: 1,
                                          time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                      },function(){
                                          window.location.reload();
                                      });

                              }

                          },
                          error:function(){

                          }
                      });
                  });






              }
          });


          /*$.ajax({
              type:'get',
              url:'/budget/selBudgetLogSet',
              dataType:'json',
              success:function(res){
                  var str=''
                  if(res){
                      var i =0;
                      console.log(res.obj);


                      $.each(res.obj,function(index,item){

                          var str ="";
                          $.each(res.obj, function (index, obj) {
                              console.log(obj.userName)
                              str +=obj.userName+',';
                              $("#query_toId").val(str)
                          });

                          if(item.budgetLogSet==0){
                              $('.quanx').css('display','inline-block')
                          }
                      })
                      $('table').append(str)
                  }

              }
          })*/



      });
      function newDocument(data,resultFn) {
          $.ajax({
//              url:'/document/saveDoc',
              url:'/budget/upBudgetLogSet',
              type:'post',
              data:data,
              dataType:'json',
              success:function(result){
                  resultFn(result)
              },
              error:function(){

              }
          });
      } //end for newDocument


//      导出

      $("#outport").click(function(){
          window.location.href="<%=basePath%>/budget/outputBudgetItem";
      })







//        分页功能
        var yearfen = new Date().getFullYear();
        var ajaxPage={

            data:{
                page:1,//当前处于第几页
                pageSize:5,//一页显示几条
                useFlag:true,
                year:yearfen
            },
            page:function () {
                var me=this;
                layer.msg('加载中', {
                    icon: 16
                    ,shade: 0.01
                });
                $.post('/budget/selAllBudget?delFlag=false',me.data,function (json) {

                    var str='';
                    var arr=json.obj;
                    if(arr.length == 0){
                      var width = ($(window).width()-60)+'px';
                      str = '<li class="no_notice" style="background:#fff;text-align: center;padding: 27px 0px;border: 1px solid #c0c0c0;border-top: none;width:'+ width +';margin: 0;"><img style="margin-bottom: 20px;" src="/img/main_img/shouyekong.png" alt=""><h2 style="text-align: center;color: #666;font-size: 16px">暂无数据</h2></li>';
                    }else{
                      for(var i=0;i<arr.length;i++){
                        var item = arr[i]
                        var lineNo = arr[i].lineNo.split(',').join('')
                        str+= '<tr budgetId="'+item.budgetId+'" indata="'+item.inputTime+'">'+
                                '<td title='+undefindData(item.budgetItemNo)+'>'+undefindData(item.budgetItemNo)+'</td>'+
                                '<td title="'+undefindData(item.priveItem)+'">'+undefindData(item.priveItem)+'</td>'+
                                '<td title="'+undefindData(item.budgetItemName)+'"><span style="color:rgb(43, 127, 224);cursor:pointer" class="mingxi">'+undefindData(item.budgetItemName)+'</span></td>'+

                                '<td title="'+undefindData(lineNo)+'">'+undefindData(lineNo)+'</td>'+
                                '<td title="'+undefindData(item.itemMoney)+'">'+undefindData(item.itemMoney)+'</td>'+
                                '<td title="'+undefindData(item.remainingAmount)+'">'+undefindData(item.remainingAmount)+'</td>'+
                                '<td title="'+undefindData(item.allAdvance)+'">'+undefindData(item.allAdvance)+'</td>'+
                                '<td title="'+undefindData(item.itemManager)+'">'+undefindData(item.itemManager)+'</td>'+
                                '<td title="'+undefindData(item.deptName)+'">'+undefindData(item.deptName)+'</td>'+
                                '<td title="'+undefindData(item.itemExecuter)+'">'+undefindData(item.itemExecuter)+'</td>'+
                                '<td title="'+undefindData(item.quotaClassify)+'">'+undefindData(item.quotaClassify)+'</td>'+
                                '<td>'+function(){
                                  if(item.isOpen==0){
                                    var str='<span style="color:rgb(43, 127, 224);cursor:pointer" class="mingxi" >项目预算明细 </span> <span style="color:rgb(43, 127, 224);cursor:pointer" class="bianji">编辑 </span> <span class="del" style="color:#CC2222;cursor:pointer">删除 </span>'
                                    return  str
                                  }else if(item.isOpen==1){
                                    var str1='<span style="color:rgb(43, 127, 224);cursor:pointer" class="mingxi" >项目预算明细 </span>'
                                    return  str1
                                  }
                                }()+'</td>'+
                                //                            '<td><a class="mingxi" href="javascript:;">填报明细 </a> <a href="javascript:;" class="bianji">编辑 </a> <a href="javascript:;" class="del" >删除 </a></td>'+
                                '</tr>'
                        if(item.budgetLogSet==0){
                          $('.quanx').css('display','inline-block')
                        }

                      }
                    }

                    $('#u268 table tbody').html(str)
                    layer.closeAll();
                    me.pageTwo(json.totleNum,me.data.pageSize,me.data.page)
                },'json')
            },
            pageTwo:function (totalData, pageSize,indexs) {
                var mes=this;
                $('#dbgz_page').pagination({
                    totalData: totalData,
                    showData: pageSize,
                    prevContent:'上一页',
                    nextContent:'下一页',
                    jump: true,
                    coping: true,
                    homePage:'',
                    endPage: '',
                    current:indexs||1,
                    callback: function (index) {
                        mes.data.page=index.getCurrent();
                        mes.page();
                    }
                });
            }
        }


        ajaxPage.page();
      $('#forPage').change(function(){
          ajaxPage.data.page = 1;
          ajaxPage.data.pageSize = $('#forPage').val();
          ajaxPage.page();
      })

        $('#query').click(function(){
            ajaxPage.data.year = $('.year').val();
            ajaxPage.data.deptId = $('#deptName').val();
            ajaxPage.data.itemExecuter = $('#user').attr('user_id');
            ajaxPage.page();
        })










  })

</script>
</html>
